package com.attendancesystem.controller;


import com.attendancesystem.service.CourseService;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import javax.servlet.annotation.WebServlet;
import java.io.IOException;
@WebServlet(name = "DeleteCourseController", value = "/DeleteCourseController")
public class DeleteCourseController extends HttpServlet {
    @Override
   protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        int courseId= Integer.parseInt(req.getParameter("courseId"));
        System.out.println("courseId:"+courseId);
        CourseService courseService = new CourseService();
        if(courseService.deleteCourse(courseId)){
            resp.getWriter().write("success");
        }else{
            resp.getWriter().write("failed");
        }
    }
}
